bitkeeper revision 1.838 (406ee03fYGZuu3lTbdwwYlwJxSLZtw)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sat, 3 Apr 2004 16:03:11 +0000 (16:03 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sat, 3 Apr 2004 16:03:11 +0000 (16:03 +0000)
shadow.h, perfc.h, memory.c, keyhandler.c, Makefile, irq.c, Rules.mk:
  Code and build cleanups. Allow perf counters to be disabled at build time by 'nperfc=y'. Allow debugging to be turned on with 'debug=y'.

xen/Rules.mk
xen/arch/i386/Rules.mk
xen/arch/i386/irq.c
xen/common/Makefile
xen/common/keyhandler.c
xen/common/memory.c
xen/include/xen/perfc.h
xen/include/xen/shadow.h

index da2d24cdda7934adb486be956e37b9448b87b7fb..237bbbd6e198e75e53fae64dd8c4abe7aae9aef8 100644 (file)
@@ -36,6 +36,14 @@ HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
 
 include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
 
+ifneq ($(debug),y)
+CFLAGS += -DNDEBUG
+endif
+
+ifeq ($(nperfc),y)
+CFLAGS += -DNPERFC
+endif
+
 ifeq ($(nodev),y)
 CFLAGS += -DNO_DEVICES_IN_XEN
 CFLAGS := $(subst -Werror,,$(CFLAGS))
index 7a72c837892a75b5ef1faba9602fd07e7ee3898a..b2a30bffeeef1fd52469f7b41f0ea3ffec1c1934 100644 (file)
@@ -9,8 +9,7 @@ MONITOR_BASE := 0xFC500000
 LOAD_BASE    := 0x00100000
 CFLAGS  := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing -O3
 CFLAGS  += -iwithprefix include -Wall -Werror -DMONITOR_BASE=$(MONITOR_BASE)
-CFLAGS  += -fomit-frame-pointer -I$(BASEDIR)/include -D__KERNEL__ -DNDEBUG
-#CFLAGS  += -fomit-frame-pointer -I$(BASEDIR)/include -D__KERNEL__
+CFLAGS  += -fomit-frame-pointer -I$(BASEDIR)/include -D__KERNEL__
 CFLAGS  += -Wno-pointer-arith -Wredundant-decls -m32
 TARGET_CPU := i686
 CFLAGS += -march=$(TARGET_CPU)
index f09590b7a290f8787c9ea7ec5792f1d7d32b463e..4c50bb592d65c7aa8a2b4687ccde2235e0da16f2 100644 (file)
@@ -476,15 +476,17 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
      * handled by some other CPU. (or is disabled)
      */
     int irq = regs.orig_eax & 0xff; /* high bits used in ret_from_ code  */
-    int cpu = smp_processor_id();
     irq_desc_t *desc = irq_desc + irq;
     struct irqaction * action;
     unsigned int status;
 
-    u32     cc_start, cc_end;
+#ifndef NPERFC
+    int cpu = smp_processor_id();
+    u32 cc_start, cc_end;
 
     perfc_incra(irqs, cpu);
     rdtscl(cc_start);
+#endif
 
     spin_lock(&desc->lock);
     desc->handler->ack(irq);
@@ -550,6 +552,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
     desc->handler->end(irq);
     spin_unlock(&desc->lock);
 
+#ifndef NPERFC
     rdtscl(cc_end);
 
     if ( !action || (!(action->flags & SA_NOPROFILE)) )
@@ -560,6 +563,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
             printk("Long interrupt %08x -> %08x\n", cc_start, cc_end);
 #endif
     }
+#endif /* NPERFC */
 
     return 1;
 }
index aa35bdb4054208228bcec391782004a575559494..c660a8b24b4818a754012579f90f0da956aef62b 100644 (file)
@@ -1,6 +1,10 @@
 
 include $(BASEDIR)/Rules.mk
 
+ifeq ($(nperfc),y)
+OBJS := $(subst perfc.o,,$(OBJS))
+endif
+
 default: $(OBJS)
        $(LD) $(LDARCHFLAGS) -r -o common.o $(OBJS)
 
index 2f6a38417c9d4b67a1593a1d1776e3735da3f4a1..92248bcca62bc6d31789b64f6477cf7ca88bdbbe 100644 (file)
@@ -104,11 +104,13 @@ void do_task_queues(u_char key, void *dev_id, struct pt_regs *regs)
     read_unlock_irqrestore(&tasklist_lock, flags); 
 }
 
-extern void perfc_printall (u_char key, void *dev_id, struct pt_regs *regs);
-extern void perfc_reset (u_char key, void *dev_id, struct pt_regs *regs);
 extern void dump_runq(u_char key, void *dev_id, struct pt_regs *regs);
 extern void print_sched_histo(u_char key, void *dev_id, struct pt_regs *regs);
 extern void reset_sched_histo(u_char key, void *dev_id, struct pt_regs *regs);
+#ifndef NPERFC
+extern void perfc_printall (u_char key, void *dev_id, struct pt_regs *regs);
+extern void perfc_reset (u_char key, void *dev_id, struct pt_regs *regs);
+#endif
 #ifndef NDEBUG
 void reaudit_pages(u_char key, void *dev_id, struct pt_regs *regs);
 void audit_all_pages(u_char key, void *dev_id, struct pt_regs *regs);
@@ -128,12 +130,14 @@ void initialize_keytable(void)
     add_key_handler('h', show_handlers, "show this message");
     add_key_handler('l', print_sched_histo, "print sched latency histogram");
     add_key_handler('L', reset_sched_histo, "reset sched latency histogram");
-    add_key_handler('p', perfc_printall, "print performance counters"); 
-    add_key_handler('P', perfc_reset,    "reset performance counters"); 
     add_key_handler('q', do_task_queues, "dump task queues + guest state");
     add_key_handler('r', dump_runq,      "dump run queues");
     add_key_handler('B', kill_dom0,      "reboot machine gracefully"); 
     add_key_handler('R', halt_machine,   "reboot machine ungracefully"); 
+#ifndef NPERFC
+    add_key_handler('p', perfc_printall, "print performance counters"); 
+    add_key_handler('P', perfc_reset,    "reset performance counters"); 
+#endif
 #ifndef NDEBUG
     add_key_handler('m', reaudit_pages, "re-audit pages");
     add_key_handler('M', audit_all_pages, "audit all pages");
index 90c96c0ea5600cbd5efd96e23c0173ce800c1f64..c632b946c61ca04ee49c1c0aec5821797555c3d7 100644 (file)
@@ -164,7 +164,7 @@ static void free_l1_table(struct pfn_info *page);
 static int mod_l2_entry(l2_pgentry_t *, l2_pgentry_t, unsigned long);
 static int mod_l1_entry(l1_pgentry_t *, l1_pgentry_t);
 
-/* frame table size and its size in pages */
+/* Frame table and its size in pages. */
 struct pfn_info *frame_table;
 unsigned long frame_table_size;
 unsigned long max_page;
@@ -770,17 +770,19 @@ void free_page_type(struct pfn_info *page, unsigned int type)
              (get_shadow_status(&current->mm, 
                                 page-frame_table) & PSH_shadowed) )
         {
-            /* using 'current-mm' is safe because page type changes only
-               occur within the context of the currently running domain as 
-               pagetable pages can not be shared across domains. The one
-               exception is when destroying a domain. However, we get away 
-               with this as there's no way the current domain can have this
-               mfn shadowed, so we won't get here... Phew! */
-
+            /*
+             * Using 'current->mm' is safe and correct because page-table pages 
+             * are not shared across domains. Updates to such pages' types are 
+             * thus only done within the context of the owning domain. The one 
+             * exception is when destroying a domain; however, this is not a 
+             * problem as the currently-executing domain will not have this 
+             * MFN shadowed, and at domain end-of-day we explicitly unshadow 
+             * everything so that nothing will get left lying around.
+             */
             unshadow_table( page-frame_table, type );
             put_shadow_status(&current->mm);
         }
-        return;
+        break;
 
     case PGT_l2_page_table:
         free_l2_table(page);
@@ -791,7 +793,7 @@ void free_page_type(struct pfn_info *page, unsigned int type)
             unshadow_table( page-frame_table, type );
             put_shadow_status(&current->mm);
         }
-        return;
+        break;
 
     default:
         BUG();
@@ -1150,7 +1152,7 @@ int do_update_va_mapping(unsigned long page_nr,
             perfc_incrc(shadow_update_va_fail);
         }
 
-        check_pagetable( p, p->mm.pagetable, "va" ); /* debug */
+        check_pagetable(p, p->mm.pagetable, "va"); /* debug */
     }
 
     deferred_ops = percpu_info[cpu].deferred_ops;
index 0f84c266dc25541d520c566b9c54faa61c8fcfad..5396be9c065dee4c11100556d4a138f10cc83cd1 100644 (file)
@@ -2,6 +2,8 @@
 #ifndef __XEN_PERFC_H__
 #define __XEN_PERFC_H__
 
+#ifndef NPERFC
+
 #include <asm/atomic.h>
 
 /* 
@@ -65,4 +67,22 @@ extern struct perfcounter_t perfcounters;
 #define perfc_addc(x,y)   atomic_add((y), &perfcounters.x[smp_processor_id()])
 #define perfc_adda(x,y,z) atomic_add((z), &perfcounters.x[y])
 
+#else /* !NPERFC */
+
+#define perfc_value(x)    ((void)0)
+#define perfc_valuec(x)   ((void)0)
+#define perfc_valuea(x,y) ((void)0)
+#define perfc_set(x,v)    ((void)0)
+#define perfc_setc(x,v)   ((void)0)
+#define perfc_seta(x,y,v) ((void)0)
+#define perfc_incr(x)     ((void)0)
+#define perfc_decr(x)     ((void)0)
+#define perfc_incrc(x)    ((void)0)
+#define perfc_incra(x,y)  ((void)0)
+#define perfc_add(x,y)    ((void)0)
+#define perfc_addc(x,y)   ((void)0)
+#define perfc_adda(x,y,z) ((void)0)
+
+#endif /* !NPERFC */
+
 #endif /* __XEN_PERFC_H__ */
index f5c0d5327aff8fdf44693d172d4dd9e486358249..c8dce726760db5a6886f30640ebcea888ecff728 100644 (file)
@@ -525,9 +525,9 @@ static inline void shadow_mk_pagetable( struct mm_struct *mm )
 
 
 #if SHADOW_DEBUG
-extern int check_pagetable( struct mm_struct *m, pagetable_t pt, char *s );
+extern int check_pagetable(struct mm_struct *m, pagetable_t pt, char *s);
 #else
-#define check_pagetable( m, pt, s )
+#define check_pagetable(m, pt, s) ((void)0)
 #endif